package kfs.light.ui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;

import kfs.light.core.Core;
import kfs.light.core.Starter;

public class MainPanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4809300982666514845L;
	
	protected JButton startButton; 
	protected JButton stopButton;
	
	public MainPanel(){
	startButton = new JButton("Start");
	stopButton = new JButton("Stop");
	
	startButton.setEnabled(true);
	stopButton.setEnabled(false);
	
	add(startButton);
	add(stopButton);
	
	startButton.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			Starter.core.setDaemon(true);
			Starter.core.start();
			startButton.setEnabled(false);
			stopButton.setEnabled(true);
			
		}
	});
	
	stopButton.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			Starter.core.exit();
			Starter.core.interrupt();
			Starter.core = new Core();
			startButton.setEnabled(true);
			stopButton.setEnabled(false);
		}
	});
	}

}
